package JitTest;

import commander.CLI;
import core.JitAdd;
import core.JitCommit;
import gitobject.Blob;
import gitobject.Commit;
import gitobject.Tree;
import org.junit.Test;

public class test5_JitCommit {
    @Test
    public void test() throws Exception {
        // 初始化仓库
        String[] sInit1 = {"jit","init","C:\\Users\\Alphamxy\\Desktop\\test"};
        CLI.jitInit(sInit1);

        JitAdd.add("TestDir");

        // 提交index
        System.out.println("Commit Info:");
        JitCommit.commit("hahaha");

        String commit_1 = Commit.getLastCommit();

//        System.out.println("=======commit=======");
//        System.out.println(Commit.deserialize(commit_1));
        System.out.println("=======tree=======");
        System.out.println(Tree.deserialize(Commit.deserialize(commit_1).getTree()).getValue());
        System.out.println("=======blob=======");
        System.out.println(Tree.deserialize(Commit.deserialize(commit_1).getTree()).getValue().split(" ")[2]);
        System.out.println(Blob.deserialize(Tree.deserialize(Commit.deserialize(commit_1).getTree()).getValue().split(" ")[2]).getValue());
    }
}